Don't print warnings when -q is passed
authorAlex Crichton <alex@alexcrichton.com>
Thu, 14 Apr 2016 17:25:25 +0000 (10:25 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 14 Apr 2016 17:25:53 +0000 (10:25 -0700)
Closes #2571

src/cargo/core/shell.rs
tests/test_cargo_install.rs

index 57876c97188402ec9015691c9393cd97ecb742c3..95750ef34809b38e6ce9995337a8ce5c7abc99f7 100644 (file)
@@ -100,7 +100,10 @@ impl MultiShell {
     }
 
     pub fn warn<T: fmt::Display>(&mut self, message: T) -> CargoResult<()> {
-        self.err().say_status("warning:", message, YELLOW, false)
+        match self.verbosity {
+            Quiet => Ok(()),
+            _ => self.err().say_status("warning:", message, YELLOW, false),
+        }
     }
 
     pub fn set_verbosity(&mut self, verbose: bool, quiet: bool) -> CargoResult<()> {
index 59270d11771bc0891ad9ff70e5c6347e1a0c4dd3..31d9bf7fcd817dfde419f85e6dc5eac2c7917153 100644 (file)
@@ -644,3 +644,18 @@ test!(git_with_lockfile {
     assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()),
                 execs().with_status(0));
 });
+
+test!(q_silences_warnings {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.1.0"
+            authors = []
+        "#)
+        .file("src/main.rs", "fn main() {}");
+    p.build();
+
+    assert_that(cargo_process("install").arg("-q").arg("--path").arg(p.root()),
+                execs().with_status(0).with_stderr(""));
+});